using System;
using System.Collections.Generic;
using System.Text;

namespace A4G.Core
{
	public class LookupGapMethodProvider : IGapMethodProvider
	{
		public LookupGapMethodProvider(double[] constants)
		{
			_constants = constants;
		}

		private readonly double[] _constants;
		public double[] Constants
		{
			get { return _constants; }
		}

		#region IGapMethodProvider Members
		public double CalculateGapPenalty(int gaps)
		{
			if (gaps < 1)
			{
				return 0;
			}

			double result = 0.0;
			if (gaps >= Constants.Length)
			{
				result = Constants[Constants.Length - 1];
			}
			else
			{
				result = Constants[gaps];
			}

			if (result > -1.0)
			{
				result = -1.0;
			}

			return result;
		}
		#endregion
	}
}
